/*
 ***************************************************************************************
 *  Copyright (C) 2006 EsperTech, Inc. All rights reserved.                            *
 *  http://www.espertech.com/esper                                                     *
 *  http://www.espertech.com                                                           *
 *  ---------------------------------------------------------------------------------- *
 *  The software in this package is published under the terms of the GPL license       *
 *  a copy of which has been included with this distribution in the license.txt file.  *
 ***************************************************************************************
 */
package com.espertech.esper.common.internal.event.json.core;

import java.util.Iterator;
import java.util.Set;

public class JsonEventUnderlyingKeySetIterator implements Iterator<String> {
    private final JsonEventObjectBase jeu;
    private final Iterator<String> keyIter;
    private int count;

    public JsonEventUnderlyingKeySetIterator(JsonEventObjectBase jeu, Set<String> keySet) {
        this.jeu = jeu;
        this.keyIter = keySet.iterator();
    }

    public boolean hasNext() {
        return count < jeu.getNativeSize() || keyIter.hasNext();
    }

    public String next() {
        if (count < jeu.getNativeSize()) {
            return jeu.getNativeKey(count++);
        }
        return keyIter.next();
    }
}
